<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./lib/react.development.js"></script>
    <script src="./lib/react-dom.development.js"></script>
    <script src="./lib/babel.min.js"></script>
</head>
<body>
<div id="root">

</div>

</body>
<script type="text/babel">
    // 合成事件：不等同于原生事件
    // 1-原生事件的属性名全部小写，而合成事件名字采用的是小驼峰命名
    // 2-原生事件的属性值是字符串，而合成事件的值是一个函数
    const root = ReactDOM.createRoot(document.querySelector("#root"));
    function fn(){
        console.log(this);// undefined
    }
    function fn2(){
        return function(){
            console.log("fn2",this);// fn2 undefined
        }
    }

    const obj = {
        fn5(){
            console.log("obj->fn5",this,this===obj);
        }
    }
    function fn6(){
        obj.fn5();
    }
    root.render((
        <div>
            <button onClick={fn}>1</button>
            <button onClick={fn2()}>2</button>
            <button onClick={function fn3() {
                console.log("fn3", this)
            }}>3
            </button>
            <button onClick={()=> {
                console.log("fn4", this)
            }}>4
            </button>
            <button onClick={obj.fn5}>5</button>
            <button onClick={fn6}>6</button>
            <button onClick={obj.fn5.bind(obj)}>7</button>
        </div>
    ))
</script>
</html>